﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

namespace FYPDemo
{
    public partial class Member_Report : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string member = txtMember.Text;
            string email = txtEmail.Text;
            string dateFrom = "";
            string dateTo= "";

            if (txtRegisteredDate.Text != "")
            {
                dateFrom = txtRegisteredDate.Text + " 00:00:00.000";
            }

            if (txtRegisteredTo.Text != "")
            {
                dateTo = txtRegisteredTo.Text + " 23:59:59.998";
            }

            int stat = Convert.ToInt32(rbStatus.SelectedValue);

            DataTable dt = new DataTable();

            dt = BackOffice_Report.MemberReport1(member, email, dateFrom, dateTo, stat);

            MemberReport_Grid.DataSource = dt;
            MemberReport_Grid.DataBind();

            lblMemberCount.Text = dt.Rows.Count.ToString();
            
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;

            string year = dt.Year +"";
            string month = dt.Month + "";
            string day = dt.Day + "";
            string fileName = "MemberReport" + year + month + day;
            GridViewExportUtil.Export(fileName+".xls", this.MemberReport_Grid);
        }  
    }
}